package com.atguigu.staservice.schedule;

import com.atguigu.commonutils.DateUtil;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author fxy
 * @date 2022/5/16 10:31
 */
@Component
public class ScheduledTack {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

//    @Scheduled(cron = "0/5 * * * * ?")//每隔五秒执行一次
//    public void tack1(){
//        System.out.println("===========tack1");
//    }

    // 在每天凌晨一点 把前一天数据进行查询添加
    @Scheduled(cron = "* * 1 * * ? ")
    public void task2(){
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(),-1)));
    }
}
